window.CQ_Analytics||(window.CQ_Analytics={}); (function(){CQ_Analytics.DataProvider=function(){function h(a){return a&&"string"==typeof a?(a=a.match(/\$\{([\w/]*)\}/ig))?a:[]:[]}var e=window.ContextHub,l=window.ClientContext,k=e||l,d=k;return{hasStore:function(a){return d===e?"undefined"!==ContextHub.getStore(a):"undefined"!==CQ_Analytics.CCM.stores[a]},getStores:function(){if(d===e){var a={},c=ContextHub.getAllStores();Object.keys(c).forEach(function(b,g){b=c[b];a[b.name]={};a[b.name].data=b.getTree()});return a}return CQ_Analytics.CCM.getStores()}, setItem:function(a,c,b){d===e?ContextHub.setItem("/store/"+a+"/"+c,b):CQ_Analytics.CCM.stores[a].setProperty(c,b)},getItem:function(a,c){return d===e?ContextHub.getItem("/store/"+a+"/"+c)||"":CQ_Analytics.CCM.stores[a].getProperty(c)},reset:function(a){d===e?ContextHub.getStore(a).reset():CQ_Analytics.CCM.stores[a].reset()},exists:function(){return d===e?ContextHub&&ContextHub.version:CQ_Analytics&&CQ_Analytics.ClientContextMgr&&CQ_Analytics.ClientContextMgr.isConfigLoaded},onReady:function(a){if(d=== e)ContextHub.eventing.on([ContextHub.Constants.EVENT_ALL_STORES_READY,ContextHub.Constants.EVENT_STORES_PARTIALLY_READY],function(c,b){a.call(this)},null,!0);else CQ_Analytics.CCM.areStoresInitialized?a.call(this):CQ_Analytics.CCM.addListener("storesinitialize",function(c){a.call(this)})},setType:function(a){d=a},getType:function(){return d?d:k},replaceVariables:function(a){if(!a)return a;var c="",b=a;for(a=h(a);0 f.length?null:f.substring(2,f.length-1);var m=d===e?ContextHub.getItem(f):CQ_Analytics.ClientContext.get(f);b=b.replace(new RegExp("\\$\\{"+f+"\\}","ig"),m)}c+=a.join();a=h(b)}return b}}}()})();